/*
 * ShaderManager.h
 *
 *  Created on: 03/11/2011
 *      Author: faust
 */

#ifndef SHADERMANAGER_H_
#define SHADERMANAGER_H_

#include <QCAR/Tool.h>
#include "Geometry/Model3D.h"

class ShaderManager
{
public:
	// Shader id
	unsigned int textureShaderID;
	unsigned int colorShaderID;

	// Returns a singleton instance of ShaderManager
	static ShaderManager* getInstance();

	// Create the needed shaders and save their id
	void createShaders();

	// Load the shader with the given id
	void loadShaders();

	// Set the current shader to use and initialize its attributes
	void useShader(unsigned int shaderId, Model3D* model,  QCAR::Matrix44F mvpMatrix );

	// Uninitialize the shader parameters
	void disableShader(unsigned int shaderId);

private:

	ShaderManager(){};

	// Texture shader handlers
	GLint texVertexHandle;
	GLint texNormalHandle;
	GLint textureCoordHandle;
	GLint texMvpMatrixHandle;

	// Color shader handlers
	GLint colorVertexHandle;
	GLint colorNormalHandle;
	GLint colorMvpMatrixHandle;
	GLint colorHandle;

	static ShaderManager* instance;
	static bool initialized;
};

#endif /* SHADERMANAGER_H_ */
